#include <iostream>
using namespace std;

//递归乘法
//不用 * 号，写乘法
class Solution {
public:
    int _multiply(int min_num, int max_num)
    {
        if (min_num == 0)
            return 0;
        else 
            return max_num+_multiply(min_num-1, max_num);
    }

    int multiply(int A, int B) {
        int ret = 0;
        int tmpA = abs(A);
        int tmpB = abs(B);
        int min_num = tmpA < tmpB ? tmpA : tmpB;
        int max_num = tmpA > tmpB ? tmpA : tmpB;

        //正负判断
        if ((A<0&&B>0) || (A>0&&B<0))
        {
            ret = _multiply(min_num, -max_num);
        }
        else
        {
            ret = _multiply(min_num, max_num);
        }

        return ret;
    }
};


// 挑7
//输出 1到n之间 的与 7 有关数字的个数。一个数与7有关是指这个数是 7 的倍数，或者是包含 7 的数字
bool haveSeven(int num)
{
    while (num)
    {
        if (num % 10 == 7)
        {
            return true;
        }
        num /= 10;
    }
    return false;
}

int main()
{
    int n = 0;
    cin >> n;
    int count = 0;
    for (int i = 7; i<=n; ++i)
    {
        if (i%7==0 || haveSeven(i))
        {
            ++count;
        }
    }
    cout << count << endl;
    return 0;
}